package algorithm.exam.sort;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class largestNumber {

    public String largestNumber(int[] nums) {

        List<String> list =new ArrayList<>();
        for(int i=0;i<nums.length;i++){
            list.add(nums[i]+"");
        }
        list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                String a=o1+o2;
                String b=o2+o1;
                return b.compareTo(a);
            }
        });
        String  res="";
        for (String s : list) {
            res=res+s;
        }
        return res;
    }
}
